   <#include
"../common/common.html"/> <@layout>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/cbb/artDialog/skins/blue.css">
    <script src="${ctx}/static/cbb/artDialog/jquery.artDialog.js"></script>
    <script type="text/javascript">
    //open new window
    function newModels(){
        var url = '${ctx}/codes/newModes' ;
        initArtDialog({url:url, title:'新增', width:650, height:450,lock:true,background: '#EAEAEA'});
    }

    var url;
    /**
     * 鎵撳紑鏂板妯″瀷鐨勮〃鍗曪紝褰曞叆淇℃伅
     */
    function newModel() {
        $('#dlg').dialog('setTitle', '新增模型').dialog('open');
        $('#myform').form('clear');
        url = '${ctx}/codes/save';
    }
    /**
     * 缂栬緫閫変腑鐨勬ā鍨嬩俊鎭�
     */
    function editModel() {
        var row = $('#dt-grid').datagrid('getSelected');
        if (row) {
//            $('#dlg').dialog('setTitle', '修改模型').dialog('open');
//            $('#myform').form('load', row);
            url = '${ctx}/codes/newModes?id=' + row.id;
            initArtDialog({url:url, title:'淇敼', width:650, height:450,lock:true,background: '#EAEAEA'});
        } else {
            $.messager.show({
                title : '修改',
                msg : '请先选择模型，再进行修改。',
                timeout:2000
            });
        }
    }
    /**
     * 鍒犻櫎閫変腑鐨勬ā鍨嬩俊鎭�
     */
    function deleteModel() {
        var row = $('#dt-grid').datagrid('getSelected');
        if (row) {
            $.messager.confirm('确认', '您确定要删除选中的模型吗?', function(r) {
                if (r) {
                    $.post('${ctx}/codes/delete/' + row.id, function(data) {
                        $.messager.show({
                            title : '提示',
                            msg : data,
                            timeout:2000
                        });
                        $('#dt-grid').datagrid('reload'); // reload the user data
                    },"text");
                }
            });
        } else {
            $.messager.show({
                title : '提示',
                msg : '请先选择模型，再进行删除。',
                timeout:2000
            });
        }
    }
    /**
     * 保存新增的用户数据，并对登录密码进行校验
     */
    function saveModel() {
        $('#myform').form('submit', {
            url : url,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                $('#dlg').dialog('close');
                $('#dt-grid').datagrid('reload');
                $.messager.show({ // show error message
                    title : '提示',
                    msg : data,
                    timeout:2000
                });
            }
        });
    }
    /**
     * 鏍规嵁鏌ヨ鏉′欢杩涜鏌ヨ锛屽悇鏉′欢闇�鍔犱笂query鏍峰紡锛屼互渚垮嚱鏁拌嚜鍔ㄦ彁鍙栨煡璇㈠弬鏁�
     */
    function queryModel() {
        $('#dt-grid').datagrid('load',$.getQueryParam('queryTable'));
    }
    /**
     * 鍙栨秷grid缁勪欢鐨勯�涓姸鎬�
     */
    function unCheckModel() {
        $('#dt-grid').datagrid('uncheckAll');
    }
</script>
<body class="easyui-layout">
	<div data-options="region:'north'" style="height: 35px; padding: 2px">
		<table id='queryTable' cellpadding="0" cellspacing="0"
			class="form-table" align='center'>
			<tr>
				<td style="width: 100px">娴嬭瘯锛�/td>
				<td style="width: 180px"><input name="search_EQ_test" id="test"
					class="query" style="width: 150px" /></td>
				<td><a href="#" class="easyui-linkbutton"
					data-options="iconCls:'icon-search'" onclick="queryModel()">查询</a></td>
			</tr>
		</table>
	</div>
	<div region="center" border="false">
		<table id="dt-grid" class="easyui-datagrid"
			data-options="url:'${ctx}/codes/query',fit:true,fitColumns:true,idField:'id',border:false,pagination:true,rownumbers:true,singleSelect:true,toolbar:'#toolbar'">
			<thead>
				<tr>
					 					<th field="type" width="100">码表类别</th>
					  					<th field="code" width="100">码表代码</th>
					  					<th field="name" width="100">码表名称</th>
					  					<th field="descinfo" width="100">码表描述</th>
					  					<th field="pid" width="100">上级码表</th>
					  					<th field="rmk" width="100">备注</th>
					     
				</tr>
			</thead>
		</table>
		<div id="toolbar">
			<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:'true'" onclick="newModels()">新增</a>
			<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-edit',plain:'true'"
				onclick="editModel()">编辑</a> <a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-remove',plain:'true'"
				onclick="deleteModel()">删除</a> <a href="#"
				class="easyui-linkbutton"
				data-options="iconCls:'icon-undo',plain:'true'"
				onclick="unCheckModel()">取消</a>
		</div>
	</div>

</body>
 </@layout> 
